/**
 * This class is the view for the Main view of the application.
 */
Ext.define('DragonApp.view.pack.filter.QualityGroup', {
    extend: 'Ext.form.RadioGroup',

    xtype: 'pack_quality_group',

    fieldLabel: '条件细分',

    defaultType: 'radiofield',
    defaults: {
        width: 130
    },

    items: [
        { boxLabel: '不限', name: 'quality', inputValue: '0', checked: true },
        { boxLabel: '普通', name: 'quality', inputValue: '普通' },
        { boxLabel: '稀有', name: 'quality', inputValue: '稀有' },
        { boxLabel: '史诗', name: 'quality', inputValue: '史诗' },
        { boxLabel: '传说', name: 'quality', inputValue: '传说' }
    ],
    listeners: {
        change: {
            fn: function() {
                var value = this.getValue();
                var store = Ext.data.StoreManager.lookup('jsonPPackStore');

                for (key in value) {
                    //清理条件过滤
                    store.clearFilter();

                    //字段筛选
                    if ('0' != value[key]) {
                        store.filter(key, value[key]);
                    }
                }
            }
        }
    }
});
